<?xml version="1.0" encoding="windows-1250"?>
<gxsl:stylesheet xmlns:gxsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/TransformAlias" xml:space="default">
  <gxsl:namespace-alias stylesheet-prefix="xsl" result-prefix="gxsl"/>
  <gxsl:output method="xml" encoding="windows-1250" indent="yes"/>
    
  <gxsl:template name="writelabel">
    <gxsl:param name="dp"/>
    <gxsl:param name="cvi"/>
    <gxsl:param name="lengthlimit"/>
        
    <gxsl:choose>
      <gxsl:when test="$cvi/CVITitles/CVITitle[@id_cttype='maintitle']/Title and $cvi/CVITitles/CVITitle[@id_cttype='maintitle']/Title!=''">
        <gxsl:value-of select="$cvi/CVITitles/CVITitle[@id_cttype='maintitle']/Title"/>:
      </gxsl:when>
      <gxsl:otherwise>
        <gxsl:value-of select="$cvi/Concept/@name"/>:
      </gxsl:otherwise>
    </gxsl:choose>  
              
    <gxsl:choose>
      <gxsl:when test="count($cvi/CVIProperties/CVIProperty[@onlabel='1'])!=0">
        <gxsl:for-each select="$cvi/CVIProperties/CVIProperty[@onlabel='1']">

          <gxsl:choose>            
            <gxsl:when test="PropGroup/@basegroup='true'">
            
              <gxsl:variable name="concept">
                <gxsl:choose>
                  <gxsl:when test="RefProp">  
                    <gxsl:value-of select="../../@concept"/>
                  </gxsl:when>
                  <gxsl:otherwise>
                    <gxsl:value-of select="@concept"/>
                  </gxsl:otherwise>
                </gxsl:choose>
              </gxsl:variable>
    
              <gxsl:variable name="attr">
                <gxsl:choose>
                  <gxsl:when test="RefProp">  
                    <gxsl:choose>
                      <gxsl:when test="RefProp[1]/@attr='1'"> 
                        <gxsl:value-of select="'@'"/>
                      </gxsl:when>
                      <gxsl:otherwise>
                        <gxsl:value-of select="''"/>
                      </gxsl:otherwise>
                    </gxsl:choose>
                  </gxsl:when>
                  <gxsl:when test="@attr='1'">
                    <gxsl:value-of select="'@'"/>
                  </gxsl:when>
                  <gxsl:otherwise>
                    <gxsl:value-of select="''"/>
                  </gxsl:otherwise>
                </gxsl:choose>
              </gxsl:variable>
    
              <gxsl:variable name="name">
                <gxsl:choose>
                  <gxsl:when test="RefProp">  
                    <gxsl:choose>
                      <gxsl:when test="RefProp[1]/@attr='1'"> 
                        <gxsl:value-of select="RefProp[1]/@nicknamelow"/>
                      </gxsl:when>
                      <gxsl:otherwise>
                        <gxsl:value-of select="RefProp[1]/@nickname"/>
                      </gxsl:otherwise>
                    </gxsl:choose>
                  </gxsl:when>
                  <gxsl:when test="@attr='1'">
                    <gxsl:value-of select="@lowname"/>
                  </gxsl:when>
                  <gxsl:otherwise>
                    <gxsl:value-of select="@name"/>
                  </gxsl:otherwise>
                </gxsl:choose>
              </gxsl:variable>
    
              <xsl:variable name="label">
                <gxsl:attribute name="select"><gxsl:value-of select="$dp"/>/<gxsl:value-of select="../../@conceptcoll"/>/<gxsl:value-of select="$concept"/>/<gxsl:value-of select="$attr"/><gxsl:value-of select="$name"/></gxsl:attribute>
              </xsl:variable>
    
              <xsl:choose>
                <xsl:when test="string-length($label) &lt; {$lengthlimit}">
                  <xsl:value-of select="$label"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="concat(substring($label,1,{$lengthlimit}-3),'...')"/>
                </xsl:otherwise>
              </xsl:choose>                
              <gxsl:if test="position()!=last()">
                <xsl:if test="$label!=''">,</xsl:if>&#160;
              </gxsl:if>

            </gxsl:when>
            <gxsl:otherwise>

              <gxsl:variable name="concept">
                <gxsl:value-of select="../../@concept"/>
              </gxsl:variable>
    
              <gxsl:variable name="attr">
                <gxsl:choose>
                  <gxsl:when test="RefProp">  
                    <gxsl:choose>
                      <gxsl:when test="RefProp[1]/@attr='1'"> 
                        <gxsl:value-of select="'@'"/>
                      </gxsl:when>
                      <gxsl:otherwise>
                        <gxsl:value-of select="''"/>
                      </gxsl:otherwise>
                    </gxsl:choose>
                  </gxsl:when>
                  <gxsl:when test="@attr='1'">
                    <gxsl:value-of select="'@'"/>
                  </gxsl:when>
                  <gxsl:otherwise>
                    <gxsl:value-of select="''"/>
                  </gxsl:otherwise>
                </gxsl:choose>
              </gxsl:variable>
    
              <gxsl:variable name="name">
                <gxsl:choose>
                  <gxsl:when test="RefProp">  
                    <gxsl:choose>
                      <gxsl:when test="RefProp[1]/@attr='1'"> 
                        <gxsl:value-of select="RefProp[1]/@nicknamelow"/>
                      </gxsl:when>
                      <gxsl:otherwise>
                        <gxsl:value-of select="RefProp[1]/@nickname"/>
                      </gxsl:otherwise>
                    </gxsl:choose>
                  </gxsl:when>
                  <gxsl:when test="@attr='1'">
                    <gxsl:value-of select="@nicknamelow"/>
                  </gxsl:when>
                  <gxsl:otherwise>
                    <gxsl:value-of select="@nickname"/>
                  </gxsl:otherwise>
                </gxsl:choose>
              </gxsl:variable>
    
              <xsl:variable name="label">
                <gxsl:attribute name="select"><gxsl:value-of select="$dp"/>/<gxsl:value-of select="../../@conceptcoll"/>/<gxsl:value-of select="$concept"/>/<gxsl:value-of select="$attr"/><gxsl:value-of select="$name"/></gxsl:attribute>
              </xsl:variable>
    
              <xsl:choose>
                <xsl:when test="string-length($label) &lt; {$lengthlimit}">
                  <xsl:value-of select="$label"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="concat(substring($label,1,{$lengthlimit}-3),'...')"/>
                </xsl:otherwise>
              </xsl:choose>
              <gxsl:if test="position()!=last()">
                <xsl:if test="$label!=''">,</xsl:if>&#160;
              </gxsl:if>              
                           
            </gxsl:otherwise>
          </gxsl:choose>            
          
        </gxsl:for-each>
      </gxsl:when>
      <gxsl:otherwise>
        <gxsl:for-each select="$cvi/CVIProperties/CVIProperty[PropGroup/@basegroup='true' and @key='1']">
          <xsl:value-of select="{$dp}/{../../@conceptcoll}/{@concept}/@{@lowname}"/><gxsl:if test="position()!=last()">,</gxsl:if>&#160;
        </gxsl:for-each>
      </gxsl:otherwise>
    </gxsl:choose>

<!--
    <gxsl:choose>
      <gxsl:when test="$cvi/CVIProperties/CVIProperty[PropGroup/@basegroup='true' and @onlabel='1']">
        <gxsl:for-each select="$cvi/CVIProperties/CVIProperty[PropGroup/@basegroup='true' and @onlabel='1']">

          <gxsl:variable name="concept">
            <gxsl:choose>
              <gxsl:when test="RefProp">  
                <gxsl:value-of select="../../@concept"/>
              </gxsl:when>
              <gxsl:otherwise>
                <gxsl:value-of select="@concept"/>
              </gxsl:otherwise>
            </gxsl:choose>
          </gxsl:variable>

          <gxsl:variable name="attr">
            <gxsl:choose>
              <gxsl:when test="RefProp">  
                <gxsl:choose>
                  <gxsl:when test="RefProp[1]/@attr='1'"> 
                    <gxsl:value-of select="'@'"/>
                  </gxsl:when>
                  <gxsl:otherwise>
                    <gxsl:value-of select="''"/>
                  </gxsl:otherwise>
                </gxsl:choose>
              </gxsl:when>
              <gxsl:when test="@attr='1'">
                <gxsl:value-of select="'@'"/>
              </gxsl:when>
              <gxsl:otherwise>
                <gxsl:value-of select="''"/>
              </gxsl:otherwise>
            </gxsl:choose>
          </gxsl:variable>

          <gxsl:variable name="name">
            <gxsl:choose>
              <gxsl:when test="RefProp">  
                <gxsl:choose>
                  <gxsl:when test="RefProp[1]/@attr='1'"> 
                    <gxsl:value-of select="RefProp[1]/@nicknamelow"/>
                  </gxsl:when>
                  <gxsl:otherwise>
                    <gxsl:value-of select="RefProp[1]/@nickname"/>
                  </gxsl:otherwise>
                </gxsl:choose>
              </gxsl:when>
              <gxsl:when test="@attr='1'">
                <gxsl:value-of select="@lowname"/>
              </gxsl:when>
              <gxsl:otherwise>
                <gxsl:value-of select="@name"/>
              </gxsl:otherwise>
            </gxsl:choose>
          </gxsl:variable>

          <xsl:variable name="label">
            <gxsl:attribute name="select"><gxsl:value-of select="$dp"/>/<gxsl:value-of select="../../@conceptcoll"/>/<gxsl:value-of select="$concept"/>/<gxsl:value-of select="$attr"/><gxsl:value-of select="$name"/></gxsl:attribute>
          </xsl:variable>

          <xsl:choose>
           <xsl:when test="string-length($label) &lt; {$lengthlimit}">
             <xsl:value-of select="$label"/><gxsl:if test="position()!=last()">,</gxsl:if>&#160;
           </xsl:when>
           <xsl:otherwise>
             <xsl:value-of select="concat(substring($label,1,{$lengthlimit}-3),'...')"/><gxsl:if test="position()!=last()">,</gxsl:if>&#160;
           </xsl:otherwise>
         </xsl:choose>
         
        </gxsl:for-each>
      </gxsl:when>
      
      <gxsl:when test="$cvi/CVIProperties/CVIProperty[PropGroup/@basegroup!='true' and @onlabel='1']">
        <gxsl:for-each select="$cvi/CVIProperties/CVIProperty[PropGroup/@basegroup!='true' and @onlabel='1']">

          <gxsl:variable name="concept">
            <gxsl:value-of select="../../@concept"/>
          </gxsl:variable>

          <gxsl:variable name="attr">
            <gxsl:choose>
              <gxsl:when test="RefProp">  
                <gxsl:choose>
                  <gxsl:when test="RefProp[1]/@attr='1'"> 
                    <gxsl:value-of select="'@'"/>
                  </gxsl:when>
                  <gxsl:otherwise>
                    <gxsl:value-of select="''"/>
                  </gxsl:otherwise>
                </gxsl:choose>
              </gxsl:when>
              <gxsl:when test="@attr='1'">
                <gxsl:value-of select="'@'"/>
              </gxsl:when>
              <gxsl:otherwise>
                <gxsl:value-of select="''"/>
              </gxsl:otherwise>
            </gxsl:choose>
          </gxsl:variable>

          <gxsl:variable name="name">
            <gxsl:choose>
              <gxsl:when test="RefProp">  
                <gxsl:choose>
                  <gxsl:when test="RefProp[1]/@attr='1'"> 
                    <gxsl:value-of select="RefProp[1]/@nicknamelow"/>
                  </gxsl:when>
                  <gxsl:otherwise>
                    <gxsl:value-of select="RefProp[1]/@nickname"/>
                  </gxsl:otherwise>
                </gxsl:choose>
              </gxsl:when>
              <gxsl:when test="@attr='1'">
                <gxsl:value-of select="@nicknamelow"/>
              </gxsl:when>
              <gxsl:otherwise>
                <gxsl:value-of select="@nickname"/>
              </gxsl:otherwise>
            </gxsl:choose>
          </gxsl:variable>

          <xsl:variable name="label">
            <gxsl:attribute name="select"><gxsl:value-of select="$dp"/>/<gxsl:value-of select="../../@conceptcoll"/>/<gxsl:value-of select="$concept"/>/<gxsl:value-of select="$attr"/><gxsl:value-of select="$name"/></gxsl:attribute>
          </xsl:variable>

          <xsl:choose>
           <xsl:when test="string-length($label) &lt; {$lengthlimit}">
             <xsl:value-of select="$label"/><gxsl:if test="position()!=last()">,</gxsl:if>&#160;
           </xsl:when>
           <xsl:otherwise>
             <xsl:value-of select="concat(substring($label,1,{$lengthlimit}-3),'...')"/><gxsl:if test="position()!=last()">,</gxsl:if>&#160;
           </xsl:otherwise>
          </xsl:choose>

        </gxsl:for-each>
      </gxsl:when>
      
      <gxsl:otherwise>
        <gxsl:for-each select="$cvi/CVIProperties/CVIProperty[PropGroup/@basegroup='true' and @key='1']">
          <xsl:value-of select="{$dp}/{../../@conceptcoll}/{@concept}/@{@lowname}"/><gxsl:if test="position()!=last()">,</gxsl:if>&#160;
        </gxsl:for-each>
      </gxsl:otherwise>
    </gxsl:choose>
-->
    
  </gxsl:template>
        
</gxsl:stylesheet>